﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using QuanLyVanBanBUS;

public partial class QLVB_User_ChiTietVanBan : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            layChiTietVanVanTheoMaVanBan();
        }
    }

    protected void layChiTietVanVanTheoMaVanBan()
    {
        string maVanBanURL = Request.QueryString["MaVanBan"];

        VanBanBUS vbBUS = new VanBanBUS();

        gvChiTietVanBan.DataSource = vbBUS.layChiTietVanBanTheoMaVanBan(maVanBanURL);
        gvChiTietVanBan.DataBind();
    }
    protected void gvChiTietVanBan_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        /*Label lblNoiNhan = (Label)(e.Row.FindControl("lblNoiNhan"));
        if (lblNoiNhan != null)
        {
            string sNoiNhan = string.Empty;
            string maVanBan = string.Empty;
            if (e.Row.DataItemIndex >= 0)
            {
                maVanBan = gvChiTietVanBan.DataKeys[e.Row.DataItemIndex].Value.ToString();
            }
            List<NoiNhan> lstNoiNhan = (new NoiNhanBUS()).layDanhSachMaNguoiNhanTheoMaVanBan(maVanBan);
            foreach (NoiNhan nn in lstNoiNhan)
            {
                sNoiNhan += nn.MaNguoiNhan.ToString() + "\n"; //Xuong dong
                //sNoiNhan += nn.MaNguoiNhan.ToString() + ",";    //Them dau phay ","
            }
            lblNoiNhan.Text = sNoiNhan;*/

        Label lblNoiNhan = (Label)(e.Row.FindControl("lblNoiNhan"));
        if (lblNoiNhan != null)
        {
            string sNoiNhan = string.Empty;
            string maVanBan = string.Empty;
            maVanBan = gvChiTietVanBan.DataKeys[e.Row.RowIndex].Value.ToString();
            List<NoiNhan> lstNoiNhan = (new NoiNhanBUS()).layDanhSachMaNguoiNhanTheoMaVanBanDaDuyet(maVanBan);
            foreach (NoiNhan nn in lstNoiNhan)
            {
                sNoiNhan += nn.MaNguoiNhan.ToString() + "\n"; //Xuong dong
                //sNoiNhan += nn.MaNguoiNhan.ToString() + ",";    //Them dau phay ","
            }
            lblNoiNhan.Text = sNoiNhan;
        }
    }
}